#include "pch.h"
#include <stdio.h>
#include <math.h>

typedef double(*fun)(double);

double integ(double lower, double upper, fun f, double accuracy = 0.1)
{
	double result = 0;

	for (; lower <= upper; lower += accuracy)
	{
		result += f(lower)*accuracy;
	}

	return result;
}

double f(double x)
{
	return pow(x,2);
}

int main()
{
	double lower, upper;
	printf("请输入积分下限：");
	scanf_s("%lf", &lower);
	printf("请输入积分上限：");
	scanf_s("%lf", &upper);
	double result = integ(lower, upper, f);
	printf("%lf", result);
}
